package com.csh.szhm.adapter;

import com.csh.szhm.R;
import com.csh.szhm.module.search.SzhmSearchItemBean;
import com.csh.szhm.module.search.SzhmSearchTypeBean;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

public class SzhmSelectTypeRightAdapter extends MyBaseAdapter<SzhmSearchTypeBean> {

	public SzhmSelectTypeRightAdapter(Context c) {
		super(c);
		// TODO Auto-generated constructor stub
	}

	public int mSelectPostion;

	public void setSelectPosition(int pos) {
		this.mSelectPostion = pos;
		notifyDataSetChanged();
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		HolderView holderView = null;
		if (convertView == null) {
			holderView = new HolderView();
			convertView = mLayoutInflater.inflate(
					R.layout.szhm_sort_area_item_right_layout, null);
			holderView.txt = (TextView) convertView
					.findViewById(R.id.area_right_txt_ix);
			holderView.img = (ImageView) convertView
					.findViewById(R.id.area_right_img_ix);
			convertView.setTag(holderView);
		} else {
			holderView = (HolderView) convertView.getTag();
		}
		if (mSelectPostion == position) {
			holderView.txt.setTextColor(mContext.getResources().getColor(
					R.color.main_text_color));
			holderView.img.setBackgroundResource(R.drawable.area_fg);
		} else {
			holderView.txt.setTextColor(mContext.getResources().getColor(
					android.R.color.black));
			holderView.img.setBackgroundResource(R.drawable.main_fg);
		}
		holderView.txt.setText(mData.get(position).getName());
		return convertView;
	}

	private class HolderView {
		TextView txt;
		ImageView img;
	}
}
